package com.lanou.controller;

import com.lanou.bean.Service;
import com.lanou.service.ServiceService;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/3/15.
 */
@Controller
public class BillController {
    @Resource
    ServiceService serviceService;

    @RequestMapping(value = "/bill_list")
    public String bill_list(){
        if (SecurityUtils.getSubject().isPermitted("账单管理")){
            return "bill/bill_list";
        }else {
            return "nopower";
        }
    }
    @RequestMapping(value = "/bill_item")
    public String bill_item(){
        return "bill/bill_item";
    }

    @RequestMapping(value = "/bill_service_detail")
    public String bill_service_detail(){
        return "bill/bill_service_detail";
    }

    @ResponseBody
    @RequestMapping(value = "/getAllBill")
    public List<Service> getAllBillList () {
        List<Service> services = serviceService.selectAllBill();
        return services;
    }

    @ResponseBody
    @RequestMapping(value = "/getAllBillById")
    public Service getAllBillListById(@Param("id") int id) {
        Service services = serviceService.selectAllBillById(id);
        return services;
    }
}
